//
//  DeviceFunctionCell.m
//  project
//
//  Created by 黄建华 on 2019/2/26.
//  Copyright © 2019年 黄建华. All rights reserved.
//

#import "DeviceFunctionCell.h"

@implementation DeviceFunctionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    
    return self;
}

- (void)createView {
    _setView = [[UIView alloc] init];
    [self addSubview:_setView];
}

- (void)updateCellWithModel:(NSString *)title withHeight:(CGFloat)height
{
    [_setView removeAllSubviews];
    NSLog(@"设备功能列表 title>>>>%@",title);
    _setView.frame = SNFRAME(0, 0, HHHWIDTH, 50);
    
    UILabel *labelTitle = [UILabel simpleWithRect:SNFRAME(25, height/2.0 -10, HHHWIDTH/2.0 +50, 20) withAlignment:NSTextAlignmentLeft withFontSize:15 withText:title withTextColor:SNCOLORBLACK];
    labelTitle.font = SNFONT(FitSimpleSize(15, 15, 16, 16, 18));
    labelTitle.adjustsFontSizeToFitWidth = YES;
    [_setView addSubview:labelTitle];
    labelTitle.textColor = UIColorHEX(0x161616);
    labelTitle.font = SNFONTREGULAR(17);
    
    if ([title isEqualToString:SN_Text(@"手环固件更新")]) {
        UILabel *firmwareId = [UILabel simpleWithRect:SNFRAME(HHHWIDTH-40 -180- 8,labelTitle.top, 180, 20) withAlignment:NSTextAlignmentRight withFontSize:15 withText:[NSString stringWithFormat:@"%@%d",@"V:",KK_BLEModel.bleVersion] withTextColor:UIColorHEX(0x96969F)];
        firmwareId.adjustsFontSizeToFitWidth = YES;
        [_setView addSubview:firmwareId];
    }

    if ([title isEqualToString:SN_Text(@"手环固件更新")]||[title isEqualToString:SN_Text(@"关于APP1")]) {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 14, 24)];
        [imageView setImage:UIImageNamed(@"next")];
        self.accessoryView = imageView;
    }
}

@end
